Expand description
ByteSize is an utility that easily makes bytes size representation and helps its arithmetic operations.
Example
ⓘ
extern crate bytesize;
use bytesize::ByteSize;
fn byte_arithmetic_operator() {
let x = ByteSize::mb(1);
let y = ByteSize::kb(100);
let plus = x + y;
print!("{} bytes", plus.as_u64());
let minus = ByteSize::tb(100) - ByteSize::gb(4);
print!("{} bytes", minus.as_u64());
}
It also provides its human readable string as follows:
assert_eq!("482 GiB".to_string(), ByteSize::gb(518).to_string(true));
assert_eq!("518 GB".to_string(), ByteSize::gb(518).to_string(false));
Structs
- Byte size representation
Constants
- byte size for 1 byte
- bytes size for 1 gigabyte
- bytes size for 1 gibibyte
- bytes size for 1 kilobyte
- bytes size for 1 kibibyte
- bytes size for 1 megabyte
- bytes size for 1 mebibyte
- bytes size for 1 petabyte
- bytes size for 1 pebibyte
- bytes size for 1 terabyte
- bytes size for 1 tebibyte